//
//  RHPolicyFeedCell.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2024/3/14.
//

#import "RHPolicyFeedCell.h"
#import "ZYSwitch.h"
@interface RHPolicyFeedCell()




@end
@implementation RHPolicyFeedCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        [self setupUI];
    }
    return self;
}



-(void)setupUI
{
    self.contentView.backgroundColor = CFTabViewBgColor;
    kWeakSelf;
    
    UIView *bgView = kView;
    bgView.backgroundColor = UIColor.whiteColor;
    bgView.layer.cornerRadius = 8;
    [self.contentView addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.top.mas_offset(5);
        make.right.mas_offset(-15);
        make.height.offset(50);
    }];
    
    QMUILabel *titleLab = [[QMUILabel alloc]init];
    titleLab.text = @"馈网".rh_localized;
    titleLab.textColor = kCOLOR_HEX_A(@"3F4443", 0.8);
    titleLab.font = kSYSTEMFONT(14);
    [bgView addSubview:titleLab];
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.centerY.mas_offset(0);
    }];
    
    ZYSwitch *swith = [[ZYSwitch alloc]initWithFrame:CGRectMake(0, 0, 45, 25)];
    swith.onTintColor = CMainColorGreen;
    [bgView addSubview:swith];
    [bgView addSubview:swith];
    [swith mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_offset(-15);
        make.centerY.mas_offset(0);
        make.width.offset(45);
        make.height.offset(25);
    }];
    [swith addTarget:self action:@selector(valueDidChange:) forControlEvents:UIControlEventValueChanged];
    
    QMUILabel *chgTipsLab = [[QMUILabel alloc] init];
    [chgTipsLab setText:@"开启后，系统会将多余电力自动卖入电网".rh_localized];
    chgTipsLab.numberOfLines = 0;
    [chgTipsLab setTextAlignment:NSTextAlignmentLeft];
    [chgTipsLab setFont:kSYSTEMFONT(12)];
    [chgTipsLab setTextColor:kCOLOR_HEX_A(@"3F4443", 0.6)];
    [self.contentView addSubview:chgTipsLab];
    [chgTipsLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.top.equalTo(bgView.mas_bottom).offset(15);
        make.bottom.mas_offset(-15);
    }];

}


-(void)valueDidChange:(ZYSwitch*)swith
{
    self.policyModel.content = [NSString stringWithFormat:@"%d",swith.isOn];
    
}


@end
